import Vue from 'vue'
import Vuex from 'vuex'
// import login from "./modules/login";
// import audit from "./modules/audit";

Vue.use(Vuex)

interface State {
  uid: string
  count: number
  keepAlive: Array<string>
}

const state: State = {
  uid: 'app',
  count: 0,
  keepAlive: [],
}

const getters: GetterTree<State, State> = {
  count(state: State) {
    return state.count + 2
  },
}

const mutations: MutationTree<State> = {
  addPage(state: State, payload: string) {
    state.keepAlive.push(payload)
  },
  delPage(state: State, payload: string) {
    state.keepAlive = state.keepAlive.filter((item) => item !== payload)
  },
}

const actions = {}
const store = new Vuex.Store({
  state,
  getters,
  mutations,
  actions,
  // modules: { login, audit },
})

export default store
